package com.internetCafes.spms.common.base;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.internetCafes.spms.core.model.pageModel.DataGrid;
import com.internetCafes.spms.core.utils.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BaseWebController {
    protected Logger logger = LoggerFactory.getLogger(getClass());

    protected DataGrid page2DataGrid(IPage page){
        DataGrid dataGrid = new DataGrid(page.getRecords(), page.getTotal(), (int)page.getSize(), (int)page.getCurrent());
        return dataGrid;
    }

    protected R getPageResult(IPage page){
        DataGrid dataGrid = new DataGrid(page.getRecords(), page.getTotal(), (int)page.getSize(), (int)page.getCurrent());
        return R.ok().put("page", dataGrid);
    }
}
